package com.aidex.system.controller;

import java.util.List;
import com.aidex.common.annotation.Log;
import com.aidex.common.core.domain.R;
import com.github.pagehelper.PageInfo;
import com.aidex.common.core.page.PageDomain;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.aidex.common.enums.BusinessType;
import com.aidex.common.utils.poi.ExcelUtil;
import javax.validation.constraints.*;
import org.springframework.web.bind.annotation.*;
import com.aidex.common.core.controller.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import com.aidex.system.domain.SyncEmergencyFlight;
import com.aidex.system.service.SyncEmergencyFlightService;

/**
 * 重点航班信息Controller
 * @author wll
 * @email wll
 * @date 2021-10-14
 */
@RestController
@RequestMapping("/system/syncEmergencyFlight")
public class SyncEmergencyFlightController extends BaseController
{
    @Autowired
    private SyncEmergencyFlightService syncEmergencyFlightService;

    /**
     * 查询重点航班信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:syncEmergencyFlight:list')")
    @GetMapping("/list")
    public R<PageInfo> list(SyncEmergencyFlight syncEmergencyFlight, HttpServletRequest request, HttpServletResponse response)
    {
        syncEmergencyFlight.setPage(new PageDomain(request, response));
        return R.data(syncEmergencyFlightService.findPage(syncEmergencyFlight));
    }

    /**
     * 获取重点航班信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:syncEmergencyFlight:query')")
    @GetMapping(value = "/{id}")
    public R<SyncEmergencyFlight> detail(@PathVariable("id") String id)
    {
        return R.data(syncEmergencyFlightService.get(id));
    }

    /**
     * 新增重点航班信息
     */
    @PreAuthorize("@ss.hasPermi('system:syncEmergencyFlight:add')")
    @Log(title = "重点航班信息", businessType = BusinessType.INSERT)
    @PostMapping
    public R add(@RequestBody @Validated  SyncEmergencyFlight syncEmergencyFlight)
    {
        return R.status(syncEmergencyFlightService.save(syncEmergencyFlight));
    }

    /**
     * 修改重点航班信息
     */
    @PreAuthorize("@ss.hasPermi('system:syncEmergencyFlight:edit')")
    @Log(title = "重点航班信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public R edit(@RequestBody @Validated SyncEmergencyFlight syncEmergencyFlight)
    {
        return R.status(syncEmergencyFlightService.save(syncEmergencyFlight));
    }


    /**
     * 删除重点航班信息
     */
    @PreAuthorize("@ss.hasPermi('system:syncEmergencyFlight:remove')")
    @Log(title = "重点航班信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R remove(@PathVariable String[] ids)
    {
        return R.status(syncEmergencyFlightService.deleteSyncEmergencyFlightByIds(ids));
    }


    /**
     * 导出重点航班信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:syncEmergencyFlight:export')")
    @Log(title = "重点航班信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public R export(SyncEmergencyFlight syncEmergencyFlight)
    {
        List<SyncEmergencyFlight> list = syncEmergencyFlightService.findList(syncEmergencyFlight);
        ExcelUtil<SyncEmergencyFlight> util = new ExcelUtil<SyncEmergencyFlight>(SyncEmergencyFlight.class);
        return util.exportExcel(list, "syncEmergencyFlight");
    }

}
